


part of appcommon;

class LoadingWidget extends StatelessWidget {
  const LoadingWidget({required this.builder,
    required this.future, this.placeHolderBuilder});
  final Widget Function(BuildContext context, AsyncSnapshot snapshot) builder;
  final Future future;
  final Widget Function(BuildContext)? placeHolderBuilder;
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(builder: (_, AsyncSnapshot snapshot) {
      if (snapshot.connectionState == ConnectionState.done) {
        return builder(context, snapshot);
      }
      if (placeHolderBuilder != null) {
        return placeHolderBuilder!(context);
      }
      return const Center(child: CircularProgressIndicator());
    }, future: future);
  }
}

